package com.ch.dream.asynctask;

import org.json.JSONObject;

import android.content.Context;

import com.ch.dream.base.BaseRequestAsyncTask;
import com.ch.dream.common.CommonData;
import com.ch.dream.common.CommonRequestUrl;
import com.ch.dream.net.MyHttpAPI;

public class GetShortStoryRequestAsyncTask extends BaseRequestAsyncTask {
	MyHttpAPI myHttpAPI = new MyHttpAPI(CommonRequestUrl.GETSHORTSTORY);
	public GetShortStoryRequestAsyncTask(Context context,
			RequestServerListener requestServerListener) {
		super(context, requestServerListener);
	}

	@Override
	protected Object doInBackground(Object... params) {
		JSONObject jsonObject ;
		JSONObject result;
		try{
			int i=0;
			String gotStr = "";
			while(CommonData.gotShortStoryList.size()-i>0){
				gotStr +=CommonData.gotShortStoryList.get(i)+",";
				i++;
			}
			jsonObject=(JSONObject)params[0];
			if(!gotStr.equals("")){
				gotStr = gotStr.substring(0, gotStr.length()-1);
			}
			jsonObject.put("gotStr", gotStr);
			result = myHttpAPI.requestForJson(jsonObject);
		}catch (Exception e) {
			e.printStackTrace();
			return null;
		}
		return result;
	}

}
